import React from "react";
import { Routes, Route } from "react-router-dom";
import AppLayout from "@/layouts";
import Login from "@/views/Login";
import { useSelector } from "react-redux";
import { ConfigProvider } from "antd";
import zhCN from "antd/locale/zh_CN";

export default function App() {
  const { loginStatus } = useSelector((state) => state.userSlice);
  const { themeColor, themeMotion } = useSelector((state) => state.appSlice);
  return (
    <ConfigProvider
      locale={zhCN}
      theme={{
        token: {
          colorPrimary: themeColor || "#1677FF",
          motion: themeMotion,
        },
      }}
    >
      <Routes>
        <Route
          path="/login"
          element={loginStatus ? <AppLayout /> : <Login />}
        />
        <Route path="/*" element={loginStatus ? <AppLayout /> : <Login />} />
      </Routes>
    </ConfigProvider>
  );
}
